<template>
    <div v-loading="isLoading" class="iframe">
        <!-- 积分兑换中转页面 -->
        <!-- <iframe v-if="isShowIframe" :src="pointIframe" frameborder="0" width="100%" height="700px"></iframe> -->
    </div>
</template>

<script>
import { mapState } from 'vuex'
import { getDictSelectList, closePage } from '@/utils/Common'
import { getToken, getTokenHsbankNo } from '@/utils/auth';

export default {
    name: 'creditsExchange',
    data() {
        return {
            bankCode: '',
            identityCard: '',
            sysAdmin: '',
            creditsCard: '',
            pointIframe: '',
            isShowIframe: false, //iframe是否正常显示
            isLoading: true//页面loading
        }
    },
    created() {
        this.bankCode = getTokenHsbankNo('HsbankNo')
        this.identityCard = this.cardInfo_3004.CUSTID
        this.sysAdmin = this.defaultParams.body.appHead.opeNo
        this.creditsCard = this.cardInfo_3004.CARDNO
    },
    computed: {
        ...mapState({
            cardInfo_3004: state => state.common.cardInfo_3004,
            defaultParams: state => state.common.defaultParams,
            pinFlag: state => state.common.pinFlag,
        })
    },
    mounted() {
        this.getPointFrame()
    },
    methods: {
        //通过数据字典获取iframe路径
        async getPointFrame() {
            const frameURL = await getDictSelectList("URLSJF", this);
            frameURL.forEach(item => {
                if (item.code === '7') {
                    this.pointIframe = item.label
                    return
                }
            });
            if (this.bankCode != '' && this.identityCard != '' && this.sysAdmin != '' && this.creditsCard != '' && this.pointIframe != '') {
                this.isShowIframe = true
                this.isLoading = false
            } else {
                this.$alert(
                    "加载失败，请重新进入", '提示',
                    {
                        customClass: "warning"
                    }
                )
            }
            this.pointIframe = this.pointIframe + 'bankCode=' + this.bankCode + '&identityCard=' + this.identityCard + '&sysAdmin=' + this.sysAdmin + '&creditsCard=' + this.creditsCard

            window.open(this.pointIframe, '_blank')
            closePage(this.$route, this, 1);
        }
    }


    // async getPointFrame() {

    //         console.log("frameurl:", this.frameURL);
    //         this.frameURL.forEach(item => {
    //             if (item.code === '7') {
    //                 this.pointIframe = item.label
    //                 return
    //             }
    //         });

    //         console.log(this.bankCode);
    //         console.log(this.sysAdmin);
    //         console.log(this.creditsCard);
    //         console.log(this.identityCard);
    //         // if (this.bankCode != '' && this.identityCard != '' && this.sysAdmin != '' && this.creditsCard != '' && this.pointIframe != '') {
    //         //     this.isShowIframe = true
    //         //     this.isLoading = false
    //         // } else {
    //         //     this.$alert(
    //         //         "加载失败，请重新进入",
    //         //         {
    //         //             customClass: "warning"
    //         //         }
    //         //     )
    //         // }
    //         this.pointIframe = 'http://38.19.13.17:8408/callcenter/product/list?';
    //         //urlstr=urlstr + "bankCode=6440" + "&identitycard=&sysAdmin=101" + "&creditsCard=" + "$!defaultCard";
    //         this.pointIframe = this.pointIframe + 'bankCode=6440&identityCard=' + this.identityCard + '&sysAdmin=101&creditsCard=' + this.creditsCard;
    //         console.log(this.pointIframe);
}
</script>

<style lang="scss" scoped>
.iframe {
    position: relative;
    .modelBox {
        pointer-events: none;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0);
    }
}
</style>
